import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
import store from 'store/store.js'

import VueLazyLoad from 'vue-lazyload'
Vue.use(VueLazyLoad, {
	preLoad: 1,
	loading: require('./static/gif/Yin and Yang.gif'),
	attempt: 2,
})


Vue.use(uView);

//封装展示的消息提示的方法
uni.$showMsg = function(title = '数据加载失败!', duration = 1500) {
	uni.showToast({
		title,
		duration,
		icon: 'none'
	})
}



import axios from 'axios'
axios.defaults.baseURL = 'https://api-hmugo-web.itheima.net/';
// axios.defaults.baseURL = 'https://machao.test.utools.club';


// 添加请求拦截器
axios.interceptors.request.use(function(config) {
	uni.showLoading({
		title: '加载中'
	})
	return config;
}, function(error) {
	uni.hideLoading()
	return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function(response) {
	uni.hideLoading()
	return response;
}, function(error) {
	uni.hideLoading()
	return Promise.reject(error);
});

uni.$axios = axios




Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App,
	store
})
app.$mount()
